﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EchoWx.Models
{
    /// <summary>
    /// 增删改操作通用返回结果
    /// </summary>
    public class CommonResult
    {
        /// <summary>
        /// 获取或设置操作的结果是否成功，成功则为true，否则false
        /// </summary>
        public bool Result { get; set; } = false;

        /// <summary>
        /// 获取或设置操作失败的编码
        /// </summary>
        public int ErrorCode { get; set; } = ResponseErrorCode.UnknownException;

        /// <summary>
        /// 获取或设置操作失败的文本提示
        /// </summary>
        public string ErrorMessage { get; set; } = string.Empty;
    }

    /// <summary>
    /// 返回结果集扩展
    /// </summary>
    public class CommonResultExtend : CommonResult
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        public long Id { get; set; }
    }

    /// <summary>
    /// 错误响应码集合
    /// </summary>
    public struct ResponseErrorCode
    {
        /// <summary>
        /// 未知错误类型
        /// </summary>
        public const int UnknownException = 0;

        /// <summary>
        /// 未传入片键或片键非法
        /// </summary>
        public const int NeedsKeyParameter = 10001;

        /// <summary>
        /// 相关数据已经存在
        /// </summary>
        public const int IsExistsValue = 10002;

        /// <summary>
        /// 相关数据不存在
        /// </summary>
        public const int NotExistsValue = 10003;

        /// <summary>
        /// 暂不支持此操作
        /// </summary>
        public const int NotSupported = 10004;

        /// <summary>
        /// 存在未传入的必传参数
        /// </summary>
        public const int ParametersRequired = 10005;

        /// <summary>
        /// 传入参数存在问题
        /// </summary>
        public const int InvalidParameters = 10006;

        /// <summary>
        /// 传入参数超出范围
        /// </summary>
        public const int OutOfRangeParameters = 10007;
    }
}
